package com.yiyun.blog.admin.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yiyun.blog.admin.mapper.AdminMapper;
import com.yiyun.blog.admin.pojo.Admin;
import com.yiyun.blog.admin.pojo.Permission;
import com.yiyun.blog.admin.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.xml.crypto.Data;
import java.util.List;

/**
 * @author Bao
 * @create 2022-05-12-11:09
 */
@Service
public class AdminService {

    @Autowired
    private AdminMapper adminMapper;

    public Admin findAdminByUsername(String username){
        // 根据 entity 条件，查询一条记录
        LambdaQueryWrapper<Admin> queryWrapper = new LambdaQueryWrapper();
        queryWrapper.eq(Admin::getUsername,username);
        queryWrapper.last("limit 1");
        Admin admin = adminMapper.selectOne(queryWrapper);
        return admin;
    }

    // 根据id查询权限信息
    public List<Permission> findPermissionByAdminId(Long adminId) {

        return adminMapper.findPermissionByAdminId(adminId);
    }
}
